package com.goodving.guli.fragment;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcel;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.androidquery.AQuery;
import com.goodving.guli.R;
import com.goodving.guli.activity.MainFragmentActivity;
import com.goodving.guli.model.DailyStats;
import com.goodving.guli.model.ViewPagerModel;
import com.goodving.guli.service.StepMessage;
import com.goodving.guli.utility.C1073z;
import com.goodving.guli.utility.C1076y;
import com.goodving.guli.utility.C1465g;
import com.goodving.guli.utility.C1481u;
import com.goodving.guli.utility.CalenderData;
import com.goodving.guli.utility.DailyInfoContainer;
import com.goodving.guli.utility.LdlDate;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Date;




/**
 * Created by Administrator on 2015-11-15.
 */
public class ViewPagerFragment extends BaseFragment {    public static final int CHANGE_CIRCLE = 123;
    private static final int CHECK_ACHIEVED = 3;
    private static final int MESSAGE_NOTIFICATION = 2;
    private static final int MESSAGE_UPDATE = 1;
    public static final long ONE_DAY = 86400000;
    public static final String SELECT_DAY = "selected_day";
    public static final String SEND_DATE_TO_MONTH = "SendDateToMONTH";
    private static final String SHARE_DATE = "share_date";
    public static final int THREE_DAYS = 259200000;
    public static final int THREE_HOURS = 10800000;
    public final String TAG;
    public AnimationDrawable animationDrawable;
    private int mDayCount;
    private int mDayPosition;
    public MyHandler mHandler;
    private AQuery mQuery;
    public ImageButton mRecoveryCloud;
    private ViewPager mViewPageWeek;
    private ViewPager mViewPagerDay;
    private C1073z mViewPagerDayAdapter;
    private ViewPagerModel mViewPagerModel;
//    private ab mViewPagerWeekAdapter;
    ArrayList<DailyInfoContainer> mWeekDaily;
    private int mWeekPosition;
    private final BroadcastReceiver receiver;

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        Log.e(TAG, "=============onCreateView================");
        View inflate = layoutInflater.inflate(R.layout.fragment_viewpager, viewGroup, false);
        this.mQuery = new AQuery(inflate);
        ((AQuery) this.mQuery.id((int) R.id.ib_actinonbar_share)).clicked(this, "tapRelative");
        ((AQuery) this.mQuery.id((int) R.id.ib_actionbar_today)).clicked(this, "tapRelative");
        ((AQuery) this.mQuery.id((int) R.id.ib_actinonbar_calendar)).clicked(this, "tapRelative");
        this.mRecoveryCloud = (ImageButton) inflate.findViewById(R.id.ib_actionbar_recovery);
        this.animationDrawable = (AnimationDrawable) this.mRecoveryCloud.getBackground();
        this.mViewPageWeek = (ViewPager) inflate.findViewById(R.id.viewpage_slide_week);
//        this.mViewPagerWeekAdapter = new ab(this);
//        this.mViewPageWeek.setAdapter(this.mViewPagerWeekAdapter);
//        this.mViewPageWeek.setOnPageChangeListener(new C13632());
        this.mViewPagerDay = (ViewPager) inflate.findViewById(R.id.pageView);
        this.mViewPagerDayAdapter = new C1073z(this, 0);
        this.mViewPagerDay.setAdapter(this.mViewPagerDayAdapter);
        this.mViewPagerDay.setOnPageChangeListener(new C13643());
        return inflate;
    }

    public static class MyHandler extends Handler {
        private WeakReference<ViewPagerFragment> mFragmentRef;

        public MyHandler(ViewPagerFragment viewPagerFragment) {
            this.mFragmentRef = new WeakReference(viewPagerFragment);
        }

        public void handleMessage(Message message) {
            if (this.mFragmentRef.get() != null) {
                ((ViewPagerFragment) this.mFragmentRef.get()).processMessage(message);
            }
        }
    }



    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.1 */
    class C13621 extends BroadcastReceiver {
        C13621() {
        }

        public void onReceive(Context context, Intent intent) {
            if ((ViewPagerFragment.this.getActivity() instanceof MainFragmentActivity) && !(((MainFragmentActivity) ViewPagerFragment.this.getActivity()).mFragment instanceof ViewPagerFragment)) {
                return;
            }
            if (C1465g.bl.equals(intent.getAction())) {
                ViewPagerFragment.this.mHandler.sendEmptyMessage(ViewPagerFragment.MESSAGE_UPDATE);
            } else if (C1465g.bm.equals(intent.getAction())) {
                StepMessage stepMessage = (StepMessage) intent.getParcelableExtra(C1465g.bn);
                if (stepMessage != null) {
                    Message obtainMessage = ViewPagerFragment.this.mHandler.obtainMessage();
                    obtainMessage.what = ViewPagerFragment.MESSAGE_NOTIFICATION;
                    obtainMessage.obj = stepMessage;
                    obtainMessage.sendToTarget();
                }
            } else if (C1465g.bi.equals(intent.getAction())) {
                long longExtra = intent.getLongExtra(ViewPagerFragment.SELECT_DAY, 0);
                Message message = new Message();
                message.what = ViewPagerFragment.CHANGE_CIRCLE;
                Bundle bundle = new Bundle();
                bundle.putLong(ViewPagerFragment.SELECT_DAY, longExtra);
                message.setData(bundle);
                ViewPagerFragment.this.mHandler.sendMessage(message);
            }
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.2 */
    class C13632 implements OnPageChangeListener {
        C13632() {
        }

        public void onPageScrolled(int i, float f, int i2) {
        }

        public void onPageSelected(int i) {
            ViewPagerFragment.this.mWeekPosition = i;
        }

        public void onPageScrollStateChanged(int i) {
            if (i == 0) {
                ViewPagerFragment.this.setSelectedDay(ViewPagerFragment.this.recomputeSelectedDayByWeekPosition(ViewPagerFragment.this.mWeekPosition));
            }
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.3 */
    class C13643 implements OnPageChangeListener {
        C13643() {
        }

        public void onPageSelected(int i) {
            ViewPagerFragment.this.mDayPosition = i;
            ViewPagerFragment.this.updateTitle(i);
            if (i == 0) {
                ViewPagerFragment.this.checkRecoveryData();
            }
        }

        public void onPageScrolled(int i, float f, int i2) {
        }

        public void onPageScrollStateChanged(int i) {
            if (i == 0) {
                LdlDate dateFromDayPosition = ViewPagerFragment.this.getDateFromDayPosition(ViewPagerFragment.this.mDayPosition);
                ((MainFragmentActivity) ViewPagerFragment.this.getActivity()).mLdlDate = dateFromDayPosition;
                ViewPagerFragment.this.updateWeekView(dateFromDayPosition);
            }
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.4 */
    class C13654 implements View.OnClickListener {
        C13654() {
        }

        public void onClick(View view) {
            ((AQuery) ViewPagerFragment.this.mQuery.id((int) R.id.xiaomi_autolaunch_tip)).gone();
            SharedPreferences.Editor edit = C1481u.m12082d().edit();
            edit.putLong(C1465g.f6107G, LdlDate.m8856a().getTime());
            edit.commit();
            ViewPagerFragment.this.initBottomTipView();
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.5 */
    class C13665 implements View.OnClickListener {
        C13665() {
        }

        public void onClick(View view) {
//            ViewPagerFragment.this.startActivity(new Intent(ViewPagerFragment.this.getActivity(), SettingForXiaomiActivity.class));
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.6 */
    class C13676 implements View.OnClickListener {
        C13676() {
        }

        public void onClick(View view) {
            SharedPreferences.Editor edit = C1481u.m12082d().edit();
            edit.putLong(C1465g.f6106F, LdlDate.m8856a().getTime());
            edit.commit();
            ViewPagerFragment.this.initBottomTipView();
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.7 */
    class C13687 implements View.OnClickListener {
        C13687() {
        }

        public void onClick(View view) {
            ViewPagerFragment.this.startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"));
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.8 */
    class C13698 implements View.OnClickListener {
        C13698() {
        }

        public void onClick(View view) {
            ViewPagerFragment.this.gotoLogin();
        }
    }

    /* renamed from: cn.ledongli.ldl.fragment.ViewPagerFragment.9 */
    class C13709 implements View.OnClickListener {
        C13709() {
        }

        public void onClick(View view) {
            ViewPagerFragment.this.tapCancelBackupTip();
        }
    }

    public ViewPagerFragment() {
        this.TAG = ViewPagerFragment.class.getName();
        this.mDayCount = 0;
        this.receiver = new C13621();
        this.mWeekPosition = 0;
        this.mDayPosition = 0;
    }

    public void processMessage(Message message) {
        switch (message.what) {
            case MESSAGE_UPDATE /*1*/:
                updateTodayStats();
            case MESSAGE_NOTIFICATION /*2*/:
                updateTodayNotification((StepMessage) message.obj);
            case CHECK_ACHIEVED /*3*/:
                if (getActivity() instanceof MainFragmentActivity) {
//                    ((MainFragmentActivity) getActivity()).m7822l();
                }
            case CHANGE_CIRCLE /*123*/:
                long j = message.getData().getLong(SELECT_DAY, 0);
                setSelectedDay(j == 0 ? LdlDate.m8856a() : LdlDate.m8859a(j));
            default:
        }
    }

    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        Log.e(TAG, "=============onActivityCreated================");
        this.mHandler = new MyHandler(this);
        ((MainFragmentActivity) getActivity()).mFragment = this;
    }

    private void initBottomTipView() {
        ((AQuery) this.mQuery.id((int) R.id.main_location_tip)).gone();
        ((AQuery) this.mQuery.id((int) R.id.main_backup_tip)).gone();
        ((AQuery) this.mQuery.id((int) R.id.xiaomi_autolaunch_tip)).gone();
//        SharedPreferences d = C1481u.m12082d();
        LdlDate a = LdlDate.m8856a();
//        if (C1467i.m11963e().equals("Xiaomi") && !a.m8865b(LdlDate.m8859a(d.getLong(C1465g.f6107G, 0)))) {
//            ((AQuery) this.mQuery.id((int) R.id.autolaunch_tip_cancel)).clicked(new C13654());
//            ((AQuery) this.mQuery.id((int) R.id.autolaunch_tip_setting)).clicked(new C13665());
//            if (!C1467i.m11969k()) {
//                ((AQuery) this.mQuery.id((int) R.id.xiaomi_autolaunch_tip)).visible();
//                return;
//            }
//        }
//        if (LdlMotionSensor.m11753b() || LdlMotionSensor.m11756c() || a.m8865b(LdlDate.m8859a(Long.valueOf(d.getLong(C1465g.f6106F, 0)).longValue()))) {
//            boolean z = d.getBoolean(C1465g.f6109I, true);
//            long j = d.getLong(C1465g.aw, 0);
//            if (!C1481u.m12099u() && LdlDate.m8856a().getTime() - j > 259200000 && z) {
//                ((AQuery) this.mQuery.id((int) R.id.backup_tip_text)).clicked(new C13698());
//                ((AQuery) this.mQuery.id((int) R.id.backup_tip_cancel)).clicked(new C13709());
//                ((AQuery) this.mQuery.id((int) R.id.main_backup_tip)).visible();
//                return;
//            }
//            return;
//        }
        ((AQuery) this.mQuery.id((int) R.id.location_tip_cancel)).clicked(new C13676());
        ((AQuery) this.mQuery.id((int) R.id.location_tip_setting)).clicked(new C13687());
        ((AQuery) this.mQuery.id((int) R.id.main_location_tip)).visible();
    }

    public void tapCancelBackupTip() {
        new AlertDialog.Builder(getActivity()).setTitle(getResources().getString(R.string.zhendebudengluma)).setMessage(getResources().getString(R.string.nimengyonghusuoyoushuju)).setNegativeButton(getResources().getString(R.string.buzaitishi), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                SharedPreferences.Editor edit = C1481u.m12082d().edit();
                edit.putBoolean(C1465g.f6109I, false);
                edit.commit();
                ViewPagerFragment.this.initBottomTipView();
            }
        }).setPositiveButton(getResources().getString(R.string.qudenglu), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
                ViewPagerFragment.this.gotoLogin();
            }
        }).show();
    }

    private void gotoLogin() {
//        Intent intent = new Intent(getActivity(), LoginFragmentActivity.class);
//        intent.putExtra(C1465g.bX, MESSAGE_UPDATE);
//        startActivity(intent);
    }

    public void updateData() {
        ViewPagerModel viewPagerModel = new ViewPagerModel();
        LdlDate i = LdlDate.m8856a().m8876i();
        int c = C1481u.m12080c();
        viewPagerModel.mDayCount = c;
//        for (int i2 = 0; i2 < c; i2 += MESSAGE_UPDATE) {
//            DailyStats a = StatsManagerWrapper.m8763a(C1481u.getContext(), i);
//            viewPagerModel.addCalenderData(a.m8656f(), a.m8681t(), a.m8682u());
//            i = i.m8881n();
//        }
        this.mViewPagerModel = viewPagerModel;
//        updateViewPagerWeekAdapter(this.mViewPagerModel);
        this.mDayCount = viewPagerModel.mDayCount;
        this.mViewPagerDayAdapter.f3839b = this.mDayCount;
        this.mViewPagerDayAdapter.notifyDataSetChanged();
        setSelectedDay(null);
//        updateWeekView(((MainFragmentActivity) getActivity()).mLdlDate);
        this.mHandler.sendEmptyMessage(MESSAGE_UPDATE);
    }

    public void onResume() {
        super.onResume();
        Log.e(TAG, "=============onActivityCreated================");
//        MobclickAgent.onPageStart("ViewPagerFragment");
        initBottomTipView();
        updateData();
        LdlDate a = LdlDate.m8856a();
        SharedPreferences d = C1481u.m12082d();
        long j = d.getLong(C1465g.f6104D, 0);
        if (j != 0) {
            if (a.getTime() - j > 10800000) {
                this.mViewPagerDay.setCurrentItem(this.mDayCount - 1);
            } else {
                this.mViewPagerDay.setCurrentItem(d.getInt(C1465g.f6105E, this.mDayCount - 1));
            }
        }
        checkAchievedTargetShare();
        checkRGMGenerate();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(C1465g.bl);
        intentFilter.addAction(C1465g.bm);
        intentFilter.addAction(C1465g.bi);
        getActivity().registerReceiver(this.receiver, intentFilter);
    }

    private void checkAchievedTargetShare() {
        LdlDate a = LdlDate.m8856a();
        if (this.mViewPagerDay.getCurrentItem() == this.mDayCount - 1) {
//            DailyStats a2 = StatsManagerWrapper.m8763a(C1481u.getContext(), a);
//            if (a2.m8656f() > C1481u.m12067a(a2)) {
//                SharedPreferences d = C1481u.m12082d();
//                if (a.getTime() > Long.valueOf(d.getLong(SHARE_DATE, 0)).longValue() + ONE_DAY) {
//                    SharedPreferences.Editor edit = d.edit();
//                    edit.putLong(SHARE_DATE, a.m8876i().getTime());
//                    edit.commit();
//                    this.mHandler.sendEmptyMessage(CHECK_ACHIEVED);
//                }
//            }
        }
    }

    private void checkRGMGenerate() {
        SharedPreferences d = C1481u.m12082d();
        long j = d.getLong(C1465g.az, 0);
        if (j > 0) {
            LdlDate a = LdlDate.m8857a(Double.longBitsToDouble(j));
            LdlDate a2 = LdlDate.m8856a();
            if (a2.m8876i().getTime() - a.m8876i().getTime() > ONE_DAY) {
                d.edit().putLong(C1465g.az, 0).commit();
                return;
            }
            int time = (this.mDayCount - ((int) ((a2.m8876i().getTime() - a.m8876i().getTime()) / ONE_DAY))) - 1;
            if (this.mViewPagerDay.getCurrentItem() != time) {
                this.mViewPagerDay.setScrollContainer(true);
                this.mViewPagerDay.setCurrentItem(time, true);
            }
        }
    }

    public void onPause() {
        super.onPause();
//        MobclickAgent.onPageEnd("ViewPagerFragment");
        SharedPreferences.Editor edit = C1481u.m12082d().edit();
        edit.putInt(C1465g.f6105E, this.mViewPagerDay.getCurrentItem());
        edit.putLong(C1465g.f6104D, LdlDate.m8856a().getTime());
        edit.commit();
        getActivity().unregisterReceiver(this.receiver);
    }

    public void onDestroy() {
//        C1472m.m12013a(this.TAG, "APP onDestroy");
        super.onDestroy();
//        MobclickAgent.onEvent(getActivity(), "MAIN_ACTIVITY_DESTROY");
    }

    private void checkRecoveryData() {
//        if (C1481u.m12099u()) {
//            C1158h.m8283d().setRenderer(new C1102e() {
//                public void onSuccess(Object obj) {
//                    SharedPreferences.Editor edit = C1481u.m12082d().edit();
//                    edit.putInt(C1465g.f6105E, ViewPagerFragment.this.mViewPagerDay.getCurrentItem());
//                    edit.commit();
//                    Intent intent = new Intent();
//                    intent.setClass(ViewPagerFragment.this.getActivity(), BackupRecoveryActivity.class);
//                    ViewPagerFragment.this.startActivity(intent);
//                }
//
//                public void onFailure(int i) {
//                    C1472m.m12016c(ViewPagerFragment.this.TAG, "checkRecoveryData is onFailed");
//                    switch (i) {
//                        case C2012l.Theme_checkboxStyle /*100*/:
//                            ViewPagerFragment.this.showMsg("\u524d\u9762\u6ca1\u6709\u4e86");
//                        case 110:
//                            ViewPagerFragment.this.showMsg("\u6570\u636e\u6062\u590d\u4e2d\uff0c\u8bf7\u7a0d\u540e");
//                        default:
//                    }
//                }
//            });
//        } else {
//            showMsg("\u524d\u9762\u6ca1\u6709\u4e86");
//        }
    }

    private void updateTitle(int i) {
        LdlDate a = LdlDate.m8856a();
        if (this.mDayCount - 1 == i) {
            ((AQuery) this.mQuery.id((int) R.id.ib_actionbar_current_day)).text((CharSequence) "\u4eca\u5929");
            ((AQuery) this.mQuery.id((int) R.id.ib_actionbar_today)).gone();
            return;
        }
        for (int i2 = this.mDayCount - 1; i2 > i; i2--) {
            a = a.m8881n();
        }
//        ((AQuery) this.mQuery.id((int) R.id.ib_actionbar_current_day)).text("" + C1466h.m11951a(a, "M\u6708d\u65e5"));
        ((AQuery) this.mQuery.id((int) R.id.ib_actionbar_today)).visible();
    }

    public void updateTodayNotification(StepMessage stepMessage) {
        if (this.mViewPagerDay.getCurrentItem() == this.mDayCount - 1) {
            Fragment fragment = (Fragment) this.mViewPagerDayAdapter.f3838a.get(this.mDayCount - 1);
            if (fragment instanceof PageViewListFragment) {
                ((PageViewListFragment) fragment).updateStepNotification(stepMessage);
            }
        }
    }

    public void updateTodayStats() {
//        DailyStats a = StatsManagerWrapper.m8763a(C1481u.getContext(), LdlDate.m8856a());
        DailyStats a = new DailyStats(Parcel.obtain());
//        C1472m.m12013a(this.TAG, "DailyStats.step = " + a.m8656f() + "    calories:" + a.m8653e());
//        Fragment fragment = (Fragment) this.mViewPagerDayAdapter.f3838a.get(0);
        Fragment fragment = new PageViewListFragment();//TBD, hard code here to generate today stats.
        if (fragment instanceof PageViewListFragment) {
            ((PageViewListFragment) fragment).updateStatus(a);
        }
    }

    public String getSaveShareImagePath() {
        Fragment fragment = (Fragment) this.mViewPagerDayAdapter.f3838a.get(this.mDayPosition);
        String str = "";
//        if (fragment instanceof PageViewListFragment) {
//            return ((PageViewListFragment) fragment).saveShareImage();
//        }
        return str;
    }

    public void tapLeftBtn() {
        int currentItem = this.mViewPagerDay.getCurrentItem();
        if (currentItem <= 0) {
            checkRecoveryData();
            return;
        }
        this.mViewPagerDay.setScrollContainer(true);
        this.mViewPagerDay.setCurrentItem(currentItem - 1, true);
    }

    public void tapRightBtn() {
        int currentItem = this.mViewPagerDay.getCurrentItem();
        if (currentItem >= this.mDayCount - 1) {
            showMsg("\u8bf7\u8010\u5fc3\u7b49\u5f85\uff0c\u660e\u5929\u5373\u5c06\u5230\u6765");
            return;
        }
        this.mViewPagerDay.setScrollContainer(true);
        this.mViewPagerDay.setCurrentItem(currentItem + MESSAGE_UPDATE, true);
    }

    public void showMsg(String str) {
        ((C1076y) getActivity()).m7646b(str);
    }

    public void tapRelative(View view) {
        switch (view.getId()) {
            case R.id.ib_actinonbar_share:
                tapShare();
            case R.id.ib_actinonbar_calendar:
                tapCalendar();
            case R.id.ib_actionbar_today:
                tapToday(null);
            default:
        }
    }

    private void tapShare() {
//        Intent intent = new Intent(getActivity(), ShareFragmentActivity.class);
//        intent.putExtra(C1465g.ck, getSaveShareImagePath());
//        intent.putExtra(C1465g.cj, getCurrentDailyStats());
//        startActivity(intent);
    }

    private void tapCalendar() {
        Bundle bundle = new Bundle();
        bundle.putParcelable(SEND_DATE_TO_MONTH, this.mViewPagerModel);
        ((MainFragmentActivity) getActivity()).m7818a(bundle);
    }

    public void tapToday(View view) {
        setSelectedDay(LdlDate.m8856a());
    }

    public int getDayPositionFromDate(LdlDate LdlDate) {
        LdlDate a = LdlDate.m8856a();
        if (LdlDate.after(a)) {
            return this.mDayCount - 1;
        }
        for (int i = this.mDayCount - 1; i >= 0; i--) {
            if (a.m8865b(LdlDate)) {
                return i;
            }
            a = a.m8881n();
        }
        return 0;
    }

    public LdlDate getDateFromDayPosition(int i) {
        LdlDate a = LdlDate.m8856a();
        for (int i2 = this.mDayCount - 1; i2 > i; i2--) {
            a = a.m8881n();
        }
        return a;
    }

//    public DailyStats getCurrentDailyStats() {
//        return StatsManagerWrapper.m8763a(C1481u.getContext(), getDateFromDayPosition(this.mViewPagerDay.getCurrentItem()));
//    }

//    private void updateViewPagerWeekAdapter(ViewPagerModel viewPagerModel) {
//        this.mWeekDaily = C1285g.m11511b(viewPagerModel.mCalenderDataList);
//        this.mViewPagerWeekAdapter.m7589a(this.mWeekDaily);
//        this.mViewPagerWeekAdapter.m7588a(((MainFragmentActivity) getActivity()).mLdlDate);
//        this.mViewPagerWeekAdapter.notifyDataSetChanged();
//    }

    private void updateWeekView(LdlDate LdlDate) {
        int i = 0;
//        while (i < this.mWeekDaily.size()) {
//            if (LdlDate.equals((( this.mWeekDaily.get(i)).getDailyInfoList().get(0)).f6087c)) {
//                break;
//            }
//            i += MESSAGE_UPDATE;
//        }
//        i = 0;
//        this.mViewPageWeek.setCurrentItem(i);
//        this.mViewPagerWeekAdapter.m7587a(i, LdlDate);
    }

    private void updateDayView(LdlDate LdlDate) {
        int dayPositionFromDate = getDayPositionFromDate(LdlDate);
        this.mViewPagerDay.setCurrentItem(dayPositionFromDate, true);
        updateTitle(dayPositionFromDate);
    }

    public void setSelectedDay(LdlDate LdlDate) {
        if (LdlDate != null) {
            ((MainFragmentActivity) getActivity()).mLdlDate = LdlDate;
        }
        if (((MainFragmentActivity) getActivity()).mLdlDate == null) {
            ((MainFragmentActivity) getActivity()).mLdlDate = LdlDate.m8856a();
        }
//        LdlDate LdlDate2 = (LdlDate)((CalenderData) this.mViewPagerModel.mCalenderDataList.get(0)).f6087c;
        LdlDate LdlDate2 = LdlDate.m8856a();
        Date date = ((MainFragmentActivity) getActivity()).mLdlDate;
        if (LdlDate.m8856a().before(date)) {
            LdlDate2 = LdlDate.m8856a();
        } else if (!LdlDate2.after(date)) {
            Date date2 = date;
        }
        ((MainFragmentActivity) getActivity()).mLdlDate = LdlDate2;
        updateDayView(LdlDate2);
    }

    private LdlDate recomputeSelectedDayByWeekPosition(int i) {
        if (this.mWeekDaily == null || this.mWeekDaily.size() <= i) {
            return LdlDate.m8856a();
        }
        Date date = ((CalenderData) ((DailyInfoContainer) this.mWeekDaily.get(i)).getDailyInfoList().get(0)).f6087c;
        LdlDate LdlDate = ((MainFragmentActivity) getActivity()).mLdlDate;
//        while (!date.equals(LdlDate)) {
//            if (LdlDate.after(date)) {
//                LdlDate = LdlDate.m8887t();
//            } else {
//                LdlDate = LdlDate.m8888u();
//            }
//        }
        return LdlDate;
    }

}
